cmake_minimum_required(VERSION 3.0.0)
project(test1 VERSION 0.1.0)

include(CTest)
enable_testing()
file(GLOB_RECURSE SRC_DIR_LIST ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.c)	

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
    file(GLOB_RECURSE LIB_DIR_LIST ${PROJECT_SOURCE_DIR}/lib/linux/*.so ${PROJECT_SOURCE_DIR}/lib/linux/*.a)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
    file(GLOB_RECURSE LIB_DIR_LIST ${PROJECT_SOURCE_DIR}/lib/windows/*.dll ${PROJECT_SOURCE_DIR}/lib/windows/*.a)
    file(GLOB_RECURSE SHARE_LIB_DIR_LIST ${PROJECT_SOURCE_DIR}/lib/windows/*.dll)
ENDIF ()


link_libraries( 
    ${LIB_DIR_LIST}
)
add_executable(test1 
    ${SRC_DIR_LIST}
)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

# 添加头文件
include_directories(
    ${PROJECT_SOURCE_DIR}/include
)
# 把动态库添加到运行目录
add_custom_command (TARGET test1 PRE_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${SHARE_LIB_DIR_LIST} $<TARGET_FILE_DIR:test1>
)

MESSAGE("operation system is ${CMAKE_SYSTEM}")
IF (WIN32)
	MESSAGE("Now is windows")
ELSEIF (APPLE)
	MESSAGE("Now is Apple systens.")
ELSEIF (UNIX)
	MESSAGE("Now is UNIX-like OS's.")
ENDIF ()

MESSAGE($<TARGET_FILE_DIR:test1>)
MESSAGE(${LIB_DIR_LIST})